#pragma once

#include "AceSession.h"

#include "AceEnvironment.h"

namespace ace
{
  namespace impl
  {
    class CAceSessionImpl : public ace::IAceSession
    {
    private:
      ace::CAceEnvironment& m_env;

      SDI_HANDLE m_handle;
    public:
      CAceSessionImpl(ace::CAceEnvironment& env) : m_env(env), m_handle(SDI_HANDLE_NONE)
      {
      }

      ~CAceSessionImpl()
      {
        if(isOpen()) close();
      }

      virtual SDI_HANDLE getHandle(void) const
      {
        return m_handle;
      }

      virtual bool isOpen() const
      {
        return m_handle != SDI_HANDLE_NONE;
      }

      virtual void open();
      virtual void close();

      virtual bool lock(const std::string& username, int *ret = NULL);
      virtual bool check(const std::string& username, const std::string& passcode, int *ret = NULL);
      virtual bool next(const std::string& passcode, int *ret = NULL);      

      virtual bool setPIN(const std::string& pin, int *ret = NULL);
    };
  } // namespace impl
} // namespace ace